package com.zhuoyue.common.config.rabbitmq;

import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wjming
 * @ClassName: RabbitConfig
 * @Description: 建交换机, 队列, 并建立关系
 * @Date 2021/2/22 15:17
 */
@Configuration
public class RabbitConfig {

    @Value("${topic.rabbit.gatewayWriteChannel}")
    private String gatewayWriteChannel;

    @Value("${topic.rabbit.userAddTransferHomeMessage}")
    private String userAddTransferHomeMessage;

    @Value("${topic.rabbit.addAcCenter}")
    private String addAcCenter;

    @Value("${topic.rabbit.sol.voice}")
    private String solVoice;

    @Value("${topic.ttl}")
    private Integer ttl;


    @Bean
    public Queue queueGatewayWrite() {
        Map<String, Object> arguments = new HashMap<>(1);
        arguments.put("x-message-ttl", ttl);
        return new Queue(gatewayWriteChannel, true, false, false, arguments);
    }

    @Bean
    public Queue userAddTransferHomeMessage() {
        Map<String, Object> arguments = new HashMap<>(1);
        arguments.put("x-message-ttl", ttl);
        return new Queue(userAddTransferHomeMessage, true, false, false, arguments);
    }

    @Bean
    public Queue addAcCenter() {
        Map<String, Object> arguments = new HashMap<>(1);
        arguments.put("x-message-ttl", ttl);
        return new Queue(addAcCenter, true, false, false, arguments);
    }

    @Bean
    public Queue solVoice() {
        Map<String, Object> arguments = new HashMap<>(1);
        arguments.put("x-message-ttl", ttl);
        return new Queue(solVoice, true, false, false, arguments);
    }


//    @Bean
//    public Binding bindingDirectExchange1(Queue gatewayWriteChannel, DirectExchange directExchange) {
//        return BindingBuilder.bind(gatewayWriteChannel).to(directExchange).with("routingKey1");
//    }
//
//    @Bean
//    public Binding bindingDirectExchange2(Queue smartHomeFrameProcess, DirectExchange directExchange) {
//        return BindingBuilder.bind(smartHomeFrameProcess).to(directExchange).with("routingKey2");
//    }
}
